//
// Created by konglinglong on 2020/9/24.
//

#ifndef CSP_INCLUDE_OSAL_OSSELECT_H_
#define CSP_INCLUDE_OSAL_OSSELECT_H_

#include "commDef.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct OsSelect
{
    int sendFd; /* 用于发送指示 */
    int recvFd; /* 用于接收指示 */
    char *pipeName;
} S_OsSelect;

typedef struct OsSelectInd
{
    uint32_t ind;
    uint32_t sn;
    uintptr_t data;
} S_OsSelectInd;

int32_t OS_SelectInit(S_OsSelect *self, const char* pipeName);
int32_t OS_SelectFinal(S_OsSelect *self);
int32_t OS_SelectSend(S_OsSelect *self, S_OsSelectInd *ind);
int32_t OS_SelectRecv(S_OsSelect *self, S_OsSelectInd *ind);
int32_t OS_SelectSendByFd(int fd, S_OsSelectInd *ind);
int32_t OS_SelectRecvByFd(int fd, S_OsSelectInd *ind);
int32_t OS_SelectClear(S_OsSelect *self);
int32_t OS_SelectPoll(S_OsSelect *self, int32_t timeoutMs);

#ifdef __cplusplus
}
#endif

#endif //CSP_INCLUDE_OSAL_OSSELECT_H_
